//
//  DrawView.m
//  绘制文字和图片
//
//  Created by student on 16/4/6.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "DrawView.h"

@implementation DrawView
-(void)setSelImage:(UIImage *)selImage
{
    _selImage = selImage;
    
    [self setNeedsDisplay];
}

// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
    
    //1.绘制图片
//    //bundle中的图片
//    UIImage *img = [UIImage imageNamed:@"langmuwine"];
//    [img drawAtPoint:CGPointZero];
//    [img drawInRect:CGRectMake(50, 50, 19, 45)];
//    [img drawInRect:rect];
//    //外部传入的图片
//    [self.selImage drawInRect:rect];
//    

    //2.绘制文字
    
    //普通字符串
    NSString *str = @"哈撒嘿哟asdfgh";
    //字符串格式字典
    NSMutableDictionary *textDict = [NSMutableDictionary dictionary];
    textDict[NSForegroundColorAttributeName] = [UIColor greenColor];//字体颜色
    textDict[NSFontAttributeName] = [UIFont systemFontOfSize:20];//字体大小
    //带格式的字符串
    NSAttributedString *aStr = [[NSAttributedString alloc]initWithString:@"Hellow!" attributes:textDict];
    
    [str drawAtPoint:CGPointZero withAttributes:textDict];
    
    [aStr drawAtPoint:CGPointMake(100, 50)];

}


@end
